USE [GradingSystemDb]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Examinations] (
	[ExaminationId] [int] IDENTITY(1,1) NOT NULL,
	[ScheduleId] [int] NOT NULL,
	[GroupId] [int] NOT NULL,
	[StudentCode] [nvarchar](max) NOT NULL,
	[ExaminationTypeId] [int] NOT NULL,
	[Grade] [decimal](6,2) NOT NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDttm] [datetime] NOT NULL,
	[ModifiedBy] [int] NOT NULL,
	[ModifiedDttm] [datetime] NOT NULL,
	CONSTRAINT [PK_Examinations] PRIMARY KEY CLUSTERED (
		[ExaminationId] ASC
	)
	WITH (
		PAD_INDEX=OFF, 
		STATISTICS_NORECOMPUTE=OFF, 
		IGNORE_DUP_KEY=OFF, 
		ALLOW_ROW_LOCKS=ON, 
		ALLOW_PAGE_LOCKS=ON
	) 
	ON [PRIMARY]
) 
ON [PRIMARY]

GO
ALTER TABLE	[dbo].[Examinations] WITH CHECK ADD CONSTRAINT [FK_Schedules_ScheduleId_Examinations_ScheduleId] FOREIGN KEY([ScheduleId])
REFERENCES  [dbo].[Schedules] ([ScheduleId])
GO
ALTER TABLE [dbo].[Examinations] CHECK CONSTRAINT [FK_Schedules_ScheduleId_Examinations_ScheduleId]
GO
ALTER TABLE	[dbo].[Examinations] WITH CHECK ADD CONSTRAINT [FK_ExaminationTypes_ExaminationTypeId_Examinations_ExaminationTypeId] FOREIGN KEY([ExaminationTypeId])
REFERENCES  [dbo].[ExaminationTypes] ([ExaminationTypeId])
GO
ALTER TABLE [dbo].[Examinations] CHECK CONSTRAINT [FK_ExaminationTypes_ExaminationTypeId_Examinations_ExaminationTypeId]
GO
ALTER TABLE	[dbo].[Examinations] WITH CHECK ADD CONSTRAINT [FK_ExaminationTypes_GroupId_Examinations_GroupId] FOREIGN KEY([GroupId])
REFERENCES  [dbo].[ExaminationTypes] ([GroupId])
GO
ALTER TABLE [dbo].[Examinations] CHECK CONSTRAINT [FK_ExaminationTypes_GroupId_Examinations_GroupId]

